package com.example.springLearning.part13.controller;

import com.example.springLearning.part13.config.ValidCustomized;
import com.example.springLearning.part13.dto.Student13;
import com.example.springLearning.part13.dto.StudentDTO13;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/spring/part13")
public class Spring13Controller {

//    @RequestMapping(path = "/students", method = RequestMethod.POST)
//    public String addStudent(@Validated @RequestBody Student13 student) {
//        log.info("add new student: {}", student.toString());
//        return "ok";
//    }

    @RequestMapping(path = "/students", method = RequestMethod.POST)
    public String addStudent(@ValidCustomized @RequestBody Student13 student) {
        log.info("add new student: {}", student.toString());
        return "ok";
    }

    @RequestMapping(path = "/students1", method = RequestMethod.POST)
    public String addStudent1(@ValidCustomized @RequestBody StudentDTO13 student) {
        log.info("add new student: {}", student.toString());
        return "ok";
    }
}
